using System;
using System.CodeDom.Compiler;

namespace TouchSocket.Core;

/// <summary>
/// 添加瞬态注入。
/// <para>
/// 该标签仅添加在继承<see cref="T:TouchSocket.Core.ManualContainer" />的容器上时有用。
/// </para>
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[GeneratedCode("TouchSocket.SourceGenerator", "2.1.10.0")]
internal class AddTransientInjectAttribute : BaseInjectAttribute
{
	/// <summary>
	/// 添加瞬态注入。
	/// <para>
	/// 该标签仅添加在继承<see cref="T:TouchSocket.Core.ManualContainer" />的容器上时有用。
	/// </para>
	/// </summary>
	/// <param name="fromType">注册类型</param>
	/// <param name="toType">实例类型</param>
	/// <param name="key">注册额外键</param>
	public AddTransientInjectAttribute(Type fromType, Type toType, string key)
	{
		base.FromType = fromType;
		base.ToType = toType;
		base.Key = key;
	}

	/// <summary>
	/// 添加瞬态注入。
	/// <para>
	/// 该标签仅添加在继承<see cref="T:TouchSocket.Core.ManualContainer" />的容器上时有用。
	/// </para>
	/// </summary>
	/// <param name="type">注册类型与实例类型一致</param>
	public AddTransientInjectAttribute(Type type)
		: this(type, type, null)
	{
	}

	/// <summary>
	/// 添加瞬态注入。
	/// <para>
	/// 该标签仅添加在继承<see cref="T:TouchSocket.Core.ManualContainer" />的容器上时有用。
	/// </para>
	/// </summary>
	/// <param name="fromType">注册类型</param>
	/// <param name="toType">实例类型</param>
	public AddTransientInjectAttribute(Type fromType, Type toType)
		: this(fromType, toType, null)
	{
	}
}
